<template>
	<view class="body">
		
		<view style="height: 19rpx;"></view>
		
		<view class="set-box">

			
			<view class="listbox">
				<view class="listbox_l">
					客户名称
				</view>
				<view class="listbox_r">
					<input type="text" :value="member.name" disabled="disabled"  />
				</view>
			</view>
			
			<view class="listbox">
				<view class="listbox_l">
					选择产品
				</view>
				<view class="listbox_r">
					<picker @change="bindPickerChange" range-key="name" :range="goods">
							<view class="uni-input">{{good_name?good_name:'请选择'}}</view>
						</picker>
				</view>
			</view>
			
			<view class="listbox">
				<view class="listbox_l">
					数量
				</view>
				<view class="listbox_r">
				<input type="number" value="" @input="getnumber" placeholder="请输入数量"  />
				</view>
			</view>
			
			<view class="listbox">
				<view class="listbox_l">
					成交价格
				</view>
				<view class="listbox_r">
				<input type="number"  @input="getmoneyr" placeholder="请输入价格"  />
				</view>
			</view>
			
			<view class="listbox">
				<view class="listbox_l">
					来源
				</view>
				<view class="listbox_r">
				<input type="text"  @input="getfrom" placeholder="请输入来源"  />
				</view>
			</view>
			
			<view class="listbox">
				<view class="listbox_l">
					地址
				</view>
				<view class="listbox_r">
				<input type="text" :value="address"  @input="getaddress" placeholder="请输入地址"  />
				</view>
			</view>
			
			
			<view class="listbox">
				<view class="listbox_l">
					备注
				</view>
				<view class="listbox_r">
				<input type="text" value=""  @input="getdesc" placeholder="请输入备注"  />
				</view>
			</view>
			
			<view style="height: 10rpx;"></view>
	
		</view>
		
		<view class="submits" @tap="submits" >提交</view>
		
	</view>
</template>



<script>
	

	export default {
		data() {
			return {
				array:['test1','test2'],
				index:1,
				goods:[],
				good_name:'',
				good_id:'',
				pname:'',
				member:'',
				id:'',
				desc:'',
				number:'',
				money:'',
				address:'',
				comeway:''
			}
		},
		onLoad(res) {
			var that=this;
			var id=res.id;
			this.id=res.id;
			
			this.$u.api.getProductLists({}).then(res => {
				console.log(res)
				that.goods=res.data
				
			})
			
			
			this.$u.api.getProductLists1({id:id}).then(res => {
				console.log(res)
				that.member=res.data
				that.address=res.data.detail_address
			})
			
			
		},
		methods: {
			getfrom(ret){
				this.comeway=ret.detail.value;
			},
			submits(){
				var info={};
				var that=this;
				
				info.id=this.id;
				info.good_id=this.good_id;
				info.number=this.number;
				info.money=this.money;
				info.address=this.address;
				info.desc=this.desc;
				info.comeway=this.comeway;
				
				this.$u.api.getProductLists2(info).then(res => {
					console.log(res)
					
					if	(res.code==1){
						
						uni.showToast({
							title:res.msg,
							icon:'none'
						})
						
						uni.navigateBack();
						
					}
				
				})
		
				
			},
			getmoneyr(ret){
					this.money=ret.detail.value;
			},
			getdesc(ret){
				this.desc=ret.detail.value;
			},
			
			getaddress(ret){
				this.address=ret.detail.value;
			},
			
			getmoney(ret){
				this.money=ret.detail.value;
			},
			
			getnumber(ret){
				this.number=ret.detail.value;
			},
			
			bindPickerChange(ret){
				console.log(ret);
				
				var index=ret.detail.value;
				var goods=this.goods;
				
				this.good_id=goods[index].id;
				this.good_name=goods[index].name;
				
			}
		}
	}
</script>

<style>
	
	
	.submits{
		width: 690rpx;height: 90rpx;margin: auto;margin-top: 90rpx;
		border-radius: 20rpx;
		text-align: center;line-height: 90rpx;
		background: #2B77FF;color: #ffffff;
		font-weight: bold;
		font-size: 30rpx;
	}
	
	.listbox_r>picker{
		height: 70rpx;line-height: 80rpx;
	}
	
	
	.listbox_r>input{
		height: 70rpx;line-height: 80rpx;
	}
	.listbox_r{
		height: 70rpx;
		width: 100%;border-bottom: 1px solid #ececec;
	}
	
	.listbox_l{
		height: 70rpx;line-height: 70rpx;
		font-size: 32rpx;font-weight: 500;color: #333333;
	}
	.listbox{
		width: 680rpx;height: auto;margin:15rpx auto;
	}
	
	.set-box{
		width: 710rpx;height: auto;margin: auto;
		background: #ffffff;border-radius: 10rpx;
	}
	
	.body{
		width: 100%;min-height: 100vh;
		background: #fafafa;
	}
</style>
